chore(perf): cache compiled Lua scripts across executions#28278
Draft
crenshaw-dev wants to merge 2 commits into
Draft
chore(perf): cache compiled Lua scripts across executions#28278crenshaw-dev wants to merge 2 commits into
crenshaw-dev wants to merge 2 commits into
Conversation
Reuse compiled FunctionProto objects keyed by script source to avoid re-parsing Lua on every health check and resource action invocation. Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Use the bundled argoproj.io/Rollout health script (~5 KB) with real testdata so the benchmark reflects compile cost on representative checks. Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
✅ Preview Environment deployed on Bunnyshell
See: Environment Details | Pipeline Logs Available commands (reply to this comment):
|
Bundle ReportBundle size has no change ✅ |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #28278 +/- ##
=========================================
Coverage ? 64.83%
=========================================
Files ? 425
Lines ? 59120
Branches ? 0
=========================================
Hits ? 38328
Misses ? 17234
Partials ? 3558 ☔ View full report in Codecov by Harness. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FunctionProtoobjects keyed by raw script source so health checks, resource actions, and discovery scripts skip re-parsing on every invocation.github.com/golang/groupcache/lru, same asutil/glob) keyed by script content; edits toargocd-cmcustomizations are a new key with no explicit invalidation.DoStringwithloadCompiledFunction→PCall; compilation errors are not cached.runLuaWithResourceActionParameters.Related to #28255. Independent of #28275 and #28277.
Benchmark
Uses the bundled
argoproj.io/Rollouthealth script (~5 KB) withtestdata/canary/healthy_executedAllSteps.yaml(Apple M3 Max, darwin/arm64):Roughly ~4.7× faster and ~3,225 fewer allocations per health evaluation on this representative script.
Test plan
go test ./util/lua/...TestCompiledScriptCache_ContentAddressed— same source returns same proto; script edits are distinct keysTestCompiledScriptCache_BoundedEviction— LRU cap enforcedTestCompiledScriptCache_OnOffParity— cache does not change health outputChecklist:
Made with Cursor